#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int a = 0, b = 0;
        for (int i : nums)
        {
            int a_tmp = a;
            a = (a ^ i) & (a | b);
            b = (b ^ i) & ~a_tmp;
        }
        return b;
    }
};

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int a = 0, b = 0;
        for (int i : nums)
        {
            b = (b ^ x) & ~a;
            a = (a ^ x) & ~b;
        }
        return b;
    }
};